tiny-c machine calls.html - lrb - 1/9/9

Source: pp 101-107 of Scott B. Guthery's book "Learning C with tiny-c" 1985 TAB Books Inc. - additions/modifications by Lee Bradley

The tiny-c machine calls

These machine calls are furnished with the tiny-c interpreter. They are always loaded and available for use. The function number is the last argument. Thus MC 1 is called like this:

MC('x',1)

Function: MC(character,1)
Arguments: A character value
Results: None
Action: Same as putchar in the system library

Function: MC(2)
Arguments: None
Results: A character value
Action: Same as getchar in the system library

Function: MC(mode,name,size,channel,3)
Arguments: A mode, file name, file size and channel number
Results: An open status indicator
Action: Same as fopen in the system library

Function: MC(buffer,channel,4)
Arguments: Pointer and channel number
Results: A get-status indicator
Action: Same as fread in the system library

Function: MC(from,to,5)
Arguments: Two pointers and a channel number
Results: A put-status indicator
Action: Same as fwrite in the system library

Function: MC(channel,6)
Arguments: A channel number
Results: None
Action: Same as fclose in the system library

Function: MC(from,to,bytes,7)
Arguments: Two pointers and an integer
Results: None
Action: Same as movebl in the system library

Function: MC(from,to,character,8)
Arguments: Two pointers and a character value
Results: The number of occurences between the two pointers, inclusively
Action: Same as countch in the system library

Function: MC(from,to,character,nptr,9)
Arguments: Two pointers, a character value and an integer pointer
Results: None
Action: Same as scann in the system library

Function: MC(10)
Arguments: None
Results: None
Action: Same as exit in the system library

Function: MC(facts,start,first,last,11)
Arguments: Four pointers
Results: None
Action: Guthery calls this "the magic rabbit hole" of tiny-c! It is discussed in Chapter 4 of "Learning C with tiny-c." He writes, "When MC 11 is called, a tiny-c program is invoked. The text of the program is from first to last, inclusively. Pointer last should point to a statement, while start points to a character string which is a tiny-c statement. The statement can be within the invoked program text, i.e. between first and last - but need not be. Pointer facts points to a 4-byte data area where facts about the exit condition of the invoked program are returned. The error code of the invoked program, if any, is stored in the first two bytes; the value of cursor (a tiny-c interpreter global) when the program terminated is stored in the second two bytes."

Function: MC(12)
Arguments: None
Results: A character value
Action: Same as chrdy in the system library

Function: MC(from,to,13)
Arguments: Two pointers
Results: None
Action: Same as pft in the system library

Function: MC(n,14)
Arguments: An integer
Results: None
Action: Same as pn in the system library

Function: MC(buffer,15)
Arguments: A character buffer
Results: The length of line read from the terminal
Action: Same as gs in the system library

Function: MC(start,bytes,character,16)
Arguments: A pointer, a number of bytes and a character
Results: None
Action: Same as memset in the system library

Function: MC(frequency,duration,17)
Arguments: Two integers
Results: None
Action: Same as beep in the system library